package com.qf.utils;

import com.qf.dao.UserDao;
import com.qf.dao.impl.UserDaoImpl;
import org.quartz.*;
import org.quartz.utils.Key;

import java.awt.*;
import java.util.Date;
import java.util.List;

/**
 * IntelliJ IDEA -> quartz
 * 2019/11/29 19:15
 *
 * @author zmyao
 * 别看，我是渣渣。
 */
public class UserJob implements Job {
    //任务的内容
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        UserDao userDao = new UserDaoImpl();
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap = jobDetail.getJobDataMap();
        String username =(String) jobDataMap.get("username");
        List<Task> tasks = userDao.findTaskByName(username);
        for (Task task : tasks) {
            System.out.println("执行的任务是："+task.getTaskContent()+"执行的时间："+new Date());
        }
    }
}
